package com.li.test.base;

import com.li.test.base.entity.UserInfo;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

//数组排序
public class ArrayCompare {
    public static void main(String[] args) {
        Integer[] dd = new Integer[]{1,10,222,4,5,66};
        List<Integer> cc = Arrays.stream(dd).sorted((o1, o2)-> Integer.compare(o2,o1)).collect(Collectors.toList());
        for(Integer aa : cc){
            System.out.println(aa);
        }
        UserInfo use = new UserInfo("aa",78,"李五福一号");
        UserInfo use1 = new UserInfo("cc",7,"李五福一号");
        UserInfo use2 = new UserInfo("bb",43,"李五福一号");
        UserInfo use3 = new UserInfo("ee",333,"李五福一号");
        UserInfo use4 = new UserInfo("ff",2,"李五福一号");
        UserInfo use5 = new UserInfo("gg",1,"李五福一号");
        UserInfo[] userArray = new UserInfo[]{use,use1,use2,use3,use4,use5};
        List<UserInfo> jj = Arrays.stream(userArray).sorted((o1,o2)->Integer.compare(o1.getAge(),o2.getAge())).collect(Collectors.toList());
        for(UserInfo ji :jj){
            System.out.println(ji.getAge());
        }

        Float dz = new Float(1f);
    }
}
